<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>待办事项 - Todo List</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Arial', sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .container {
            background: white;
            border-radius: 15px;
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
            overflow: hidden;
            width: 100%;
            max-width: 1200px;
            min-height: 800px;
        }
        
        .header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 20px;
            text-align: center;
            position: relative;
        }
        
        .header h1 {
            margin-bottom: 10px;
            font-size: 2.5em;
        }
        
        .nav-btn {
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            background: rgba(255, 255, 255, 0.2);
            border: 1px solid rgba(255, 255, 255, 0.3);
            color: white;
            padding: 8px 16px;
            border-radius: 20px;
            cursor: pointer;
            transition: all 0.3s ease;
            text-decoration: none;
            font-size: 14px;
        }
        
        .nav-btn:hover {
            background: rgba(255, 255, 255, 0.3);
        }
        
        .nav-btn.left {
            left: 20px;
        }
        
        .nav-btn.right {
            right: 20px;
        }
        
        .content {
            padding: 30px;
        }
        
        .todo-container {
            max-width: 700px;
            margin: 0 auto;
        }
        
        .todo-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
            padding-bottom: 20px;
            border-bottom: 2px solid #e9ecef;
        }

        .todo-header h2 {
            color: #2c3e50;
            margin: 0;
        }

        .header-actions {
            display: flex;
            gap: 10px;
        }

        .action-link {
            background: linear-gradient(135deg, #3498db, #2980b9);
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 25px;
            cursor: pointer;
            font-size: 14px;
            transition: all 0.3s ease;
            text-decoration: none;
            display: inline-block;
        }

        .action-link:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
        }
        
        .logout-btn {
            background: linear-gradient(135deg, #e74c3c, #c0392b);
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 25px;
            cursor: pointer;
            font-size: 14px;
            transition: all 0.3s ease;
        }

        .logout-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3);
        }
        
        .todo-input {
            display: flex;
            gap: 10px;
            margin-bottom: 30px;
        }
        
        .todo-input input {
            flex: 1;
            padding: 12px 15px;
            border: 2px solid #e9ecef;
            border-radius: 25px;
            font-size: 16px;
        }
        
        .todo-input button {
            padding: 12px 20px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 25px;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .todo-list {
            space-y: 10px;
        }
        
        .todo-item {
            background: #f8f9fa;
            padding: 15px 20px;
            border-radius: 15px;
            margin-bottom: 10px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            transition: all 0.3s ease;
            border-left: 4px solid transparent;
        }
        
        .todo-item:hover {
            transform: translateX(5px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }
        
        .todo-item.completed {
            opacity: 0.7;
            border-left-color: #28a745;
        }
        
        .todo-item.starred {
            border-left-color: #ffc107;
            background: #fff8e1;
        }
        
        .todo-content {
            flex: 1;
        }
        
        .todo-title {
            font-weight: 600;
            margin-bottom: 5px;
            color: #333;
        }
        
        .todo-title.completed {
            text-decoration: line-through;
            color: #6c757d;
        }
        
        .todo-desc {
            color: #6c757d;
            font-size: 14px;
        }
        
        .todo-actions {
            display: flex;
            gap: 10px;
        }
        
        .action-btn {
            padding: 6px 12px;
            border: none;
            border-radius: 15px;
            cursor: pointer;
            font-size: 12px;
            transition: all 0.3s ease;
        }
        
        .star-btn {
            background: #ffc107;
            color: white;
        }
        
        .complete-btn {
            background: #28a745;
            color: white;
        }
        
        .delete-btn {
            background: #dc3545;
            color: white;
        }
        
        .action-btn:hover {
            transform: scale(1.1);
        }
        
        .error {
            color: #dc3545;
            text-align: center;
            margin-top: 10px;
            padding: 10px;
            background: #f8d7da;
            border-radius: 10px;
        }
        
        .loading {
            text-align: center;
            padding: 20px;
            color: #6c757d;
        }
        
        .stats-summary {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-bottom: 40px;
        }
        
        .stat-card {
            background: white;
            padding: 25px 20px;
            border-radius: 20px;
            text-align: center;
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
            border: 1px solid #f0f0f0;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }
        
        .stat-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 4px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .stat-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
        }
        
        .stat-card:nth-child(1)::before {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .stat-card:nth-child(2)::before {
            background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
        }
        
        .stat-card:nth-child(3)::before {
            background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
        }
        
        .stat-card:nth-child(4)::before {
            background: linear-gradient(135deg, #e74c3c 0%, #fd79a8 100%);
        }
        
        .stat-number {
            font-size: 2.5em;
            font-weight: 700;
            margin-bottom: 8px;
            color: #2c3e50;
            line-height: 1;
        }
        
        .stat-card:nth-child(1) .stat-number {
            color: #667eea;
        }
        
        .stat-card:nth-child(2) .stat-number {
            color: #28a745;
        }
        
        .stat-card:nth-child(3) .stat-number {
            color: #ffc107;
        }
        
        .stat-card:nth-child(4) .stat-number {
            color: #e74c3c;
        }
        
        .stat-label {
            font-size: 1em;
            color: #6c757d;
            font-weight: 500;
            letter-spacing: 0.5px;
        }
        
        .stat-icon {
            font-size: 1.5em;
            margin-bottom: 10px;
            display: block;
        }
    </style>
</head>
<body>
    <div id="app">
        <div class="container">
            <div class="header">
                <a href="login.html" class="nav-btn left">← 返回登录</a>
                <h1>📝 po-todo-list</h1>
                <a href="analytics.html" class="nav-btn right">数据分析 →</a>
            </div>
            
            <div class="content">
                <div class="todo-container">
                    <div class="todo-header">
                        <h2>我的待办事项</h2>
                        <div class="header-actions">
                            <a href="analytics.html" class="action-link">
                                📊 查看数据分析
                            </a>
                            <button @click="logout" class="logout-btn">退出登录</button>
                        </div>
                    </div>
                    
                    <!-- 统计卡片 -->
                    <div class="stats-summary">
                        <div class="stat-card">
                            <div class="stat-icon">📋</div>
                            <div class="stat-number">{{ totalTodos }}</div>
                            <div class="stat-label">总任务数</div>
                        </div>
                        <div class="stat-card">
                            <div class="stat-icon">✅</div>
                            <div class="stat-number">{{ completedTodos }}</div>
                            <div class="stat-label">已完成</div>
                        </div>
                        <div class="stat-card">
                            <div class="stat-icon">⏳</div>
                            <div class="stat-number">{{ pendingTodos }}</div>
                            <div class="stat-label">待完成</div>
                        </div>
                        <div class="stat-card">
                            <div class="stat-icon">⭐</div>
                            <div class="stat-number">{{ starredTodos }}</div>
                            <div class="stat-label">重要任务</div>
                        </div>
                    </div>

                    <div class="todo-input">
                        <input 
                            type="text" 
                            v-model="newTodo.title" 
                            placeholder="添加新任务标题..."
                            @keyup.enter="addTodo"
                        >
                        <input 
                            type="text" 
                            v-model="newTodo.describe" 
                            placeholder="任务描述（可选）..."
                            @keyup.enter="addTodo"
                        >
                        <button @click="addTodo" :disabled="!newTodo.title.trim()">
                            添加
                        </button>
                    </div>
                    
                    <div v-if="loading" class="loading">
                        加载中...
                    </div>
                    
                    <div v-else class="todo-list">
                        <div 
                            v-for="todo in todos" 
                            :key="todo.id"
                            class="todo-item"
                            :class="{completed: todo.status === 1, starred: todo.star === 1}"
                        >
                            <div class="todo-content">
                                <div class="todo-title" :class="{completed: todo.status === 1}">
                                    {{ todo.title }}
                                </div>
                                <div v-if="todo.describe" class="todo-desc">
                                    {{ todo.describe }}
                                </div>
                            </div>
                            
                            <div class="todo-actions">
                                <button 
                                    @click="toggleStar(todo)"
                                    class="action-btn star-btn"
                                    :style="{opacity: todo.star === 1 ? 1 : 0.5}"
                                >
                                    ⭐
                                </button>
                                <button 
                                    @click="toggleComplete(todo)"
                                    class="action-btn complete-btn"
                                >
                                    {{ todo.status === 1 ? '取消' : '完成' }}
                                </button>
                                <button 
                                    @click="deleteTodo(todo.id)"
                                    class="action-btn delete-btn"
                                >
                                    删除
                                </button>
                            </div>
                        </div>
                        
                        <div v-if="todos.length === 0" class="loading">
                            暂无任务，添加一个新任务开始吧！
                        </div>
                    </div>
                    
                    <div v-if="error" class="error">{{ error }}</div>
                </div>
            </div>
        </div>
    </div>
    
    <script src="todo.js"></script>
</body>
</html>